package com.augurit.wf.app.shouwen.convert;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.augurit.common.util.lang.DateUtils;
import com.augurit.wf.app.shouwen.web.form.OaShouwenForm;
import com.augurit.wf.common.entity.OaShouwen;

public class OaShouwenConvertor {
	public static OaShouwenForm convertVoToForm(OaShouwen entity) {
		if(entity != null) {
			OaShouwenForm form = new OaShouwenForm();
			form.setId(entity.getId());
			form.setCode(entity.getCode());
			form.setTitle(entity.getTitle());
			form.setSeq(entity.getSeq());
			form.setDocType(entity.getDocType());
			form.setKeyWord(entity.getKeyWord());
			form.setSecret(entity.getSecret());
			form.setUrgency(entity.getUrgency());
			form.setMainSend(entity.getMainSend());
			form.setApposeSend(entity.getApposeSend());
			form.setSecrecyLimit(entity.getSecrecyLimit());
			form.setCopies(entity.getCopies());
			form.setIssuer(entity.getIssuer());
			form.setIssueDate(entity.getIssueDate());
			form.setReceivedDate(entity.getReceivedDate());
			form.setExecuteLimit(entity.getExecuteLimit());
			form.setDocSummary(entity.getDocSummary());
			form.setFromUnit(entity.getFromUnit());
			form.setContactAddress(entity.getContactAddress());
			form.setContactPhone(entity.getContactPhone());
			return form;
		}else
			return null;
	}
	
	public static void convertFormToVo(OaShouwenForm form, OaShouwen entity) {
		if(entity != null && form != null) {
			entity.setId(form.getId());
			if(form.getCode() != null && form.getCode().trim().length() > 0)
				entity.setCode(form.getCode().trim());
			if(form.getTitle() != null && form.getTitle().trim().length() > 0)
				entity.setTitle(form.getTitle().trim());
			if(form.getSeq() != null && form.getSeq().trim().length() > 0)
				entity.setSeq(form.getSeq().trim());
			if(form.getDocType() != null && form.getDocType().trim().length() > 0)
				entity.setDocType(form.getDocType().trim());
			if(form.getKeyWord() != null && form.getKeyWord().trim().length() > 0)
				entity.setKeyWord(form.getKeyWord().trim());
			if(form.getSecret() != null && form.getSecret().trim().length() > 0)
				entity.setSecret(form.getSecret().trim());
			if(form.getUrgency() != null && form.getUrgency().trim().length() > 0)
				entity.setUrgency(form.getUrgency().trim());
			if(form.getMainSend() != null && form.getMainSend().trim().length() > 0)
				entity.setMainSend(form.getMainSend().trim());
			if(form.getApposeSend() != null && form.getApposeSend().trim().length() > 0)
				entity.setApposeSend(form.getApposeSend().trim());
			if(form.getSecrecyLimit() != null && form.getSecrecyLimit().trim().length() > 0)
				entity.setSecrecyLimit(form.getSecrecyLimit().trim());
			entity.setCopies(form.getCopies());
			if(form.getIssuer() != null && form.getIssuer().trim().length() > 0)
				entity.setIssuer(form.getIssuer().trim());
			entity.setIssueDate(form.getIssueDate());
			entity.setReceivedDate(form.getReceivedDate());
			if(form.getExecuteLimit() != null && form.getExecuteLimit().trim().length() > 0)
				entity.setExecuteLimit(form.getExecuteLimit().trim());
			if(form.getDocSummary() != null && form.getDocSummary().trim().length() > 0)
				entity.setDocSummary(form.getDocSummary().trim());
			if(form.getFromUnit() != null && form.getFromUnit().trim().length() > 0)
				entity.setFromUnit(form.getFromUnit().trim());
			if(form.getContactAddress() != null && form.getContactAddress().trim().length() > 0)
				entity.setContactAddress(form.getContactAddress().trim());
			if(form.getContactPhone() != null && form.getContactPhone().trim().length() > 0)
				entity.setContactPhone(form.getContactPhone().trim());
		}
	}
	
	public static List<OaShouwenForm> convertVoListToFormList(List<OaShouwen> oaShouwenList) {
		if(oaShouwenList != null && oaShouwenList.size() > 0) {
			List<OaShouwenForm> oaShouwenFormList = new ArrayList();
			for(int i=0; i<oaShouwenList.size(); i++) {
				oaShouwenFormList.add(convertVoToForm(oaShouwenList.get(i)));
			}
			return oaShouwenFormList;
		}
		return null;
	}
	
	public static List<OaShouwen> convertFormListToVoList(List<OaShouwenForm> oaShouwenFormList) {
		if(oaShouwenFormList != null && oaShouwenFormList.size() > 0) {
			List<OaShouwen> oaShouwenList = new ArrayList();
			for(int i=0; i<oaShouwenFormList.size(); i++) {
				OaShouwen oaShouwen = new OaShouwen();
				convertFormToVo(oaShouwenFormList.get(i), oaShouwen);
				oaShouwenList.add(oaShouwen);
			}
			return oaShouwenList;
		}
		return null;
	}
}